SUBDIRS = test

staging_dir = @abs_builddir@/devel

setup_py = @abs_builddir@/setup.py
setup_cfg = @abs_builddir@/setup.cfg

GENPYTHON = @abs_top_builddir@/thrift/generated/gen-py
PYTHONPATH = $(staging_dir)

all-local:
	test "@abs_srcdir@" = "@abs_builddir@" || ( \
		(cd @abs_srcdir@ && find . -name '*.py' -exec \
			$(INSTALL) @abs_srcdir@/{} @abs_builddir@/{} \; );)
	test -d @abs_builddir@/hbase || ( \
		$(INSTALL) -d @abs_builddir@/hbase && \
		(cd $(GENPYTHON)/hbase && find . -name '*.py' -exec \
			$(INSTALL) $(GENPYTHON)/hbase/{} @abs_builddir@/hbase/{} \; );)
	test -d $(staging_dir) || \
		($(INSTALL) -d $(staging_dir) && \
		env VERSION=$(PACKAGE_VERSION) \
			PYTHONPATH=$(PYTHONPATH) \
				$(PYTHON) $(setup_py) develop \
					--install-dir=$(staging_dir))
	env VERSION=$(PACKAGE_VERSION) \
		PYTHONPATH=$(PYTHONPATH) \
			$(PYTHON) $(setup_py) build

check-local:
	env VERSION=$(PACKAGE_VERSION) \
		PYTHONPATH=$(PYTHONPATH) \
			$(PYTHON) $(setup_py) test $(TEST_SUITE)

# Make sure we honour $DESTDIR, if supplied
setup-cfg:
	rm -f $(setup_cfg)
	test -z "$(DESTDIR)" || ( \
		echo "[install]" > $(setup_cfg); \
		echo "root=$(DESTDIR)" >> $(setup_cfg))

install-exec-local: setup-cfg
	env VERSION=$(PACKAGE_VERSION) \
		$(PYTHON) $(setup_py) install

uninstall-local: setup-cfg
	env VERSION=$(PACKAGE_VERSION) \
		$(PYTHON) $(setup_py) uninstall

clean-local:
	rm -rf $(staging_dir) build dist *.egg-info $(setup_cfg) hbase
	find @abs_builddir@ -name '*.pyc' -exec rm -f {} \;
	test "@abs_srcdir@" = "@abs_builddir@" || ( \
		(cd @abs_srcdir@ && find . -name '*.py' -exec \
			rm -f @abs_builddir@/{} \; );)

EXTRA_DIST = autocrap.py ez_setup.py setup.py
